<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import = "java.sql.*" %>
<%
Class.forName("com.mysql.jdbc.Driver");

String url;
Connection conn;
ResultSet rs;
Statement stmt;

try 
{
	Class.forName("com.mysql.jdbc.Driver");
	url = "jdbc:mysql://localhost/inventory";
	conn = DriverManager.getConnection(url, "root", "");
	
	stmt = conn.createStatement();
	rs = stmt.executeQuery("Select category_code from category");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form method = "post" action="http://localhost:8080/ForFinals/AddItem">
Item Code:<input type = "text" name = "itemCode">
<br>
Item Name:<input type = "text" name = "itemName">
<br>
Item Detail:<input type = "text" name = "itemDetail">
<br>
Category Code:
<%
out.println("<SELECT>");
while (rs.next()){
out.println("<OPTION>" + rs.getObject(1).toString() + "</OPTION>");
}
out.println("</SELECT>");
}
catch(ClassNotFoundException cnfe)
{
	out.println("" + cnfe);
}
catch (SQLException sqle)
{
	out.println("" + sqle);
}
%>
<br>
Item Quantity:<input type = "text" name = "itemQuantity">
<br>
<input type = "submit">
</form>
</body>
</html>